<?php if (!defined('TL_ROOT')) die('You can not access this file directly!');

/**
 * TYPOlight webCMS
 * Copyright (C) 2005 Leo Feyer
 *
 * This program is free software: you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation, either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this program. If not, please visit the Free
 * Software Foundation website at http://www.gnu.org/licenses/.
 *
 * PHP version 5
 * @copyright  include7 AG, Flavian Sierk 
 * @author     Flavian Sierk 
 * @package    TellAFriend 
 * @license    LGPL 
 * @filesource
 */

array_insert($GLOBALS['TL_DCA']['tl_module']['palettes']['__selector__'],1,array('tellafriend_mailthis','tellafriend_addaddthis','tellafriend_disclaimer','tellafriend_addthiadvanced'));


$GLOBALS['TL_DCA']['tl_module']['palettes']['tellafriend']    = '{title_legend},name,headline,type;{config_legend},tellafriend_mailthis;tellafriend_addaddthis,tellafriend_addthiadvanced;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space';

$GLOBALS['TL_DCA']['tl_module']['subpalettes']['tellafriend_mailthis'] = 'tellafriend_subject,tellafriend_mailtext,tellafriend_sendername,tellafriend_senderemail,tellafriend_allowcustomtext,tellafriend_disablecaptcha,tellafriend_disclaimer';
$GLOBALS['TL_DCA']['tl_module']['subpalettes']['tellafriend_addaddthis'] = 'tellafriend_addthisuser, tellafriend_addthistemplate';
$GLOBALS['TL_DCA']['tl_module']['subpalettes']['tellafriend_disclaimer'] = 'tellafriend_disclaimerpage';
$GLOBALS['TL_DCA']['tl_module']['subpalettes']['tellafriend_addthiadvanced'] = 'tellafriend_atfcolor, tellafriend_atbcolor,tellafriend_atui_cobrand,tellafriend_atservices_exclude,tellafriend_atservices_compact,tellafriend_atservices_expanded,tellafriend_atui_508_compliant,tellafriend_atdata_ga_tracker,tellafriend_atdata_use_flash,tellafriend_atdata_use_cookies,tellafriend_atclick';


$GLOBALS['TL_DCA']['tl_module']['fields']['tellafriend_mailthis'] = array
(
	'label'                   => &$GLOBALS['TL_LANG']['tl_module']['tellafriend_mailthis'],
	'exclude'                 => true,
	'inputType'               => 'checkbox',
	'eval'                    => array('submitOnChange'=>true)
);

$GLOBALS['TL_DCA']['tl_module']['fields']['tellafriend_addthiadvanced'] = array
(
	'label'                   => &$GLOBALS['TL_LANG']['tl_module']['tellafriend_addthiadvanced'],
	'exclude'                 => true,
	'inputType'               => 'checkbox',
	'eval'                    => array('submitOnChange'=>true, 'tl_class' =>'clr')
);


$GLOBALS['TL_DCA']['tl_module']['fields']['tellafriend_addaddthis'] = array
(
	'label'                   => &$GLOBALS['TL_LANG']['tl_module']['tellafriend_addaddthis'],
	'exclude'                 => true,
	'inputType'               => 'checkbox',
	'eval'                    => array('submitOnChange'=>true)
);

$GLOBALS['TL_DCA']['tl_module']['fields']['tellafriend_allowcustomtext'] = array
(
	'label'                   => &$GLOBALS['TL_LANG']['tl_module']['tellafriend_allowcustomtext'],
	'exclude'                 => true,
	'inputType'               => 'checkbox',
	'eval'                    => array('tl_class'=>'w50')
);

$GLOBALS['TL_DCA']['tl_module']['fields']['tellafriend_disablecaptcha'] = array
(
	'label'                   => &$GLOBALS['TL_LANG']['tl_module']['tellafriend_disablecaptcha'],
	'exclude'                 => true,
	'inputType'               => 'checkbox',
	'eval'                    => array('tl_class'=>'w50')
);


$GLOBALS['TL_DCA']['tl_module']['fields']['tellafriend_sendername'] = array
(
	'label'                   => &$GLOBALS['TL_LANG']['tl_module']['tellafriend_sendername'],
	'exclude'                 => true,
	'inputType'               => 'checkbox',
	'eval'                    => array('tl_class'=>'w50')
	
);
$GLOBALS['TL_DCA']['tl_module']['fields']['tellafriend_senderemail'] = array
(
	'label'                   => &$GLOBALS['TL_LANG']['tl_module']['tellafriend_senderemail'],
	'exclude'                 => true,
	'inputType'               => 'checkbox',
		'eval'                    => array('tl_class'=>'w50')
);

$GLOBALS['TL_DCA']['tl_module']['fields']['tellafriend_disclaimer'] = array
(
	'label'                   => &$GLOBALS['TL_LANG']['tl_module']['tellafriend_disclaimer'],
	'exclude'                 => true,
	'inputType'               => 'checkbox',
	'eval'                    => array('submitOnChange'=>true, 'tl_class'=>'clr')
);

$GLOBALS['TL_DCA']['tl_module']['fields']['tellafriend_disclaimerpage'] = array
(
		'label'                   => &$GLOBALS['TL_LANG']['tl_module']['tellafriend_disclaimerpage'],
		'exclude'                 => true,
		'inputType'               => 'pageTree',
		'eval'                    => array('fieldType'=>'radio')
);


$GLOBALS['TL_DCA']['tl_module']['fields']['tellafriend_subject'] = array
(
	'label'                   => &$GLOBALS['TL_LANG']['tl_module']['tellafriend_subject'],
	'exclude'                 => true,
	'inputType'               => 'text',
	'eval'                    => array('mandatory'=>true, 'maxlength'=>255)
);
$GLOBALS['TL_DCA']['tl_module']['fields']['tellafriend_mailtext'] = array
(
	'label'                   => &$GLOBALS['TL_LANG']['tl_module']['tellafriend_mailtext'],
	'exclude'                 => true,
	'inputType'               => 'textarea',
	'eval'                    => array('mandatory'=>true, 'decodeEntities'=>true)
);
$GLOBALS['TL_DCA']['tl_module']['fields']['tellafriend_addthisuser'] = array
(
	'label'                   => &$GLOBALS['TL_LANG']['tl_module']['tellafriend_addthisuser'],
	'exclude'                 => true,
	'inputType'               => 'text',
	'eval'                    => array('mandatory'=>true, 'maxlength'=>255, 'tl_class'=>'w50')
);

$GLOBALS['TL_DCA']['tl_module']['fields']['tellafriend_addthistemplate'] = array
(
	'label'                   => &$GLOBALS['TL_LANG']['tl_module']['tellafriend_addthistemplate'],
	'default'                 => 'news_single',
	'exclude'                 => true,
	'inputType'               => 'select',
	'options'                 => $this->getTemplateGroup('taf_at_'),
	'eval'                    => array('tl_class'=>'w50')
);


$GLOBALS['TL_DCA']['tl_module']['fields']['tellafriend_atfcolor'] = array
(
	'label'                   => &$GLOBALS['TL_LANG']['tl_module']['tellafriend_atfcolor'],
	'inputType'               => 'text',
	'eval'                    => array('maxlength'=>6, 'rgxp'=>'alnum', 'tl_class'=>'w50 wizard'),
	'wizard' => array
	(
		array('addthis', 'colorPicker')
	)
);

$GLOBALS['TL_DCA']['tl_module']['fields']['tellafriend_atbcolor'] = array
(
	'label'                   => &$GLOBALS['TL_LANG']['tl_module']['tellafriend_atbcolor'],
	'inputType'               => 'text',
	'eval'                    => array('maxlength'=>6, 'rgxp'=>'alnum', 'tl_class'=>'w50 wizard'),
	'wizard' => array
	(
		array('addthis', 'colorPicker')
	)
);

$GLOBALS['TL_DCA']['tl_module']['fields']['tellafriend_atui_cobrand'] = array
(
	'label'                   => &$GLOBALS['TL_LANG']['tl_module']['tellafriend_atui_cobrand'],
	'exclude'                 => true,
	'inputType'               => 'text',
	'eval'                    => array('mandatory'=>false, 'maxlength'=>32, 'tl_class'=>'w50')
);

$GLOBALS['TL_DCA']['tl_module']['fields']['tellafriend_atservices_exclude'] = array
(
	'label'                   => &$GLOBALS['TL_LANG']['tl_module']['tellafriend_atservices_exclude'],
	'exclude'                 => true,
	'inputType'               => 'text',
	'eval'                    => array('mandatory'=>false, 'maxlength'=>255, 'tl_class'=>'w50')
);

$GLOBALS['TL_DCA']['tl_module']['fields']['tellafriend_atservices_expanded'] = array
(
	'label'                   => &$GLOBALS['TL_LANG']['tl_module']['tellafriend_atservices_expanded'],
	'exclude'                 => true,
	'inputType'               => 'text',
	'eval'                    => array('mandatory'=>false, 'maxlength'=>255, 'tl_class'=>'w50')
);

$GLOBALS['TL_DCA']['tl_module']['fields']['tellafriend_atservices_compact'] = array
(
	'label'                   => &$GLOBALS['TL_LANG']['tl_module']['tellafriend_atservices_compact'],
	'exclude'                 => true,
	'inputType'               => 'text',
	'eval'                    => array('mandatory'=>false, 'maxlength'=>255, 'tl_class'=>'w50')
);


$GLOBALS['TL_DCA']['tl_module']['fields']['tellafriend_atclick'] = array
(
	'label'                   => &$GLOBALS['TL_LANG']['tl_module']['tellafriend_atclick'],
	'exclude'                 => true,
	'inputType'               => 'checkbox',
		'eval'                    => array('tl_class'=>'clr')
);
$GLOBALS['TL_DCA']['tl_module']['fields']['tellafriend_atui_508_compliant'] = array
(
	'label'                   => &$GLOBALS['TL_LANG']['tl_module']['tellafriend_atui_508_compliant'],
	'exclude'                 => true,
	'inputType'               => 'checkbox',
		'eval'                    => array('tl_class'=>'w50')
);
$GLOBALS['TL_DCA']['tl_module']['fields']['tellafriend_atdata_ga_tracker'] = array
(
	'label'                   => &$GLOBALS['TL_LANG']['tl_module']['tellafriend_atdata_ga_tracker'],
	'exclude'                 => true,
	'inputType'               => 'checkbox',
		'eval'                    => array('tl_class'=>'w50')
);
$GLOBALS['TL_DCA']['tl_module']['fields']['tellafriend_atdata_use_flash'] = array
(
	'label'                   => &$GLOBALS['TL_LANG']['tl_module']['tellafriend_atdata_use_flash'],
	'exclude'                 => true,
	'inputType'               => 'checkbox',
		'eval'                    => array('tl_class'=>'w50')
);
$GLOBALS['TL_DCA']['tl_module']['fields']['tellafriend_atdata_use_cookies'] = array
(
	'label'                   => &$GLOBALS['TL_LANG']['tl_module']['tellafriend_atdata_use_cookies'],
	'exclude'                 => true,
	'inputType'               => 'checkbox',
		'eval'                    => array('tl_class'=>'w50')
);
$GLOBALS['TL_DCA']['tl_module']['fields']['tellafriend_atclick'] = array
(
	'label'                   => &$GLOBALS['TL_LANG']['tl_module']['tellafriend_atclick'],
	'exclude'                 => true,
	'inputType'               => 'checkbox',
		'eval'                    => array('tl_class'=>'clr')
);

class addthis extends Backend
{

	/**
	 * Add the mooRainbow scripts to the page
	 */
	public function __construct()
	{
		parent::__construct();

		$GLOBALS['TL_CSS'][] = 'plugins/mootools/rainbow.css';
		$GLOBALS['TL_JAVASCRIPT'][] = 'plugins/mootools/rainbow.js';
	}

	/**
	 * Return the color picker wizard
	 * @param object
	 * @return string
	 */
	public function colorPicker(DataContainer $dc)
	{
		return ' ' . $this->generateImage('pickcolor.gif', $GLOBALS['TL_LANG']['MSC']['colorpicker'], 'style="vertical-align:top; cursor:pointer;" id="moo_'.$dc->field.'" class="mooRainbow"');
	}

}
?>